<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加新闻</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/main.css" type="text/css"/>
<script type="text/javascript" src="<%=request.getContextPath() %>/xheditor/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/xheditor/xheditor-1.1.14-zh-cn.min.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	$(function(){
		$("#content").xheditor({tools:"full"});
		var ab = document.getElementById("addAttach");
		var ac = document.getElementById("attachContainer");
		ab.onclick = function(){
			var node = "<span><br/><input type='file' name='atts'/><input type='button' onclick='remove(this)' value='移除'/></span>";
			ac.innerHTML = ac.innerHTML+node;
		};
	});
	
	function remove(obj) {
		var ac = document.getElementById("attachContainer");
		ac.removeChild(obj.parentNode);
	}
	function getSortType(){
    	var sortId = document.getElementById("sort").value;
    	$.ajax({
            type:"post",        
            async:true,    //是否异步
            url:"later_news_objectToJson.action",
            data:"sortId="+sortId,
            dataType:"json",    
            success:function(data){
            	var friends = $("#ddlDatas");
            	friends.empty(); 
            	var def = $("<option>").text("----请选择二级栏目----").val(0);
            	friends.append(def);
                 data.forEach(function(val,index) {        
                	var option =$("<option>").text(val.name).val(val.id);
                	friends.append(option);
                 });
            } 
        });    
    }
</script>
</head>
<body>
<jsp:include page="nav.jsp"/>
<s:fielderror/>
<form action="later_news_update.action" method="post" enctype="multipart/form-data">
<table class="ct" width="900" align="center" cellpadding="0"
	cellspacing="0">
	<s:hidden name="id" value="#{news.id}"></s:hidden>
	<tr>
	<td>新闻标题:</td>
	<td><input type="text" size="40" name="title"/>
	</td>
	</tr>
	<tr>
		<td>选择一级栏目:</td>
		 <td>
		   <s:select list="#ds" id="sort" listKey="id" 
		   listValue="sortname" name="sortId"  theme="simple" 
		   style="width:120px;font-size:12px" headerKey="0" 
		   headerValue="--选择文本--" onchange="getSortType()" value="#{news.sort.id}"/>
		</td>
	</tr>
	<tr>
		<td>
		      选择二级栏目:
		</td>
		<td>
		   <select name="SortTypeId" id="ddlDatas" style="width:120px;font-size:12px">
		     <s:iterator value="#dts">
		      <option value="${id}">${name}</option>
		     </s:iterator>
		   </select>
		</td>
	</tr>
	<tr>
		<td >添加附件:</td>
		<td></td>
	</tr>

	<tr>
	    <td>图片上传：</td>
		<td>
			<input type="file" name="picture"/>
		</td>
	</tr>
	<tr>
		<td colspan="2">内容</td>
	</tr>
	<tr>
		<td colspan="2">
			<textarea rows="30" cols="130" id="content" name="content"></textarea>
		</td>
	</tr>
	<tr>
	<td colspan="2" align="center">
		<input type="submit" value="发送"/>
	</td>
	</tr>
</table>
</form>
</body>
</html>